#include <iostream>
#include <cstdio>
#include <algorithm>

#define MAXN 5010

using namespace std;

int gd[MAXN];	int lq[MAXN];	int dp[MAXN][MAXN];

int main(){
	int n, s;	int a, b;
	cin >> n >> s;		cin >> a >> b;
	for (int i = 1; i <= n; i++){
		scanf("%d%d",&gd[i],&lq[i]);
	}
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= s; j++){
			dp[i][j] = dp[i - 1][j];
			if ((a + b) >= gd[i] && j >= lq[i]){
				dp[i][j] = max (dp[i - 1][j], ++dp[i - 1][j - lq[i]]);
			}
		}
	}
	cout << dp[n][s] << endl;
	return 0;
}
